package com.tduck.cloud.datav.service.charts;

import cn.hutool.core.map.MapUtil;
import com.google.common.collect.Lists;
import com.tduck.cloud.datav.request.ChartDataRequest;
import com.tduck.cloud.datav.service.BaseChartDataService;
import com.tduck.cloud.report.data.params.ValueQueryParams;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 数字标题翻牌器
 *
 * @author tduck
 */
@Component
@Slf4j
public class NumberTitleFlopChartDataService extends BaseChartDataService {

    @Override
    public Map<String, Object> getChartData(ChartDataRequest request) {
        ChartDataRequest.IndexField field = request.getIndex().get(0);
        ValueQueryParams queryParams=new ValueQueryParams(field.getId(),field.getAggregateType(),field.getValue());
        queryParams.setQueryObjName(request.getIndexName());
        queryParams.setFilter(Lists.newArrayList(request.getFilter()));
        Long fieldAggregateValue = dataSearchTemplate.getFieldAggregateValue(queryParams);
        return MapUtil.of("value", fieldAggregateValue);
    }




}
